package com.youlu.campus.service.activity.impl;

import com.youlu.campus.entity.ActivityDominConfig;
import com.youlu.campus.service.activity.ActivityDominConfigService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class ActivityDominConfigServiceImpl implements ActivityDominConfigService {
    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public ActivityDominConfig find(String activityId) {
        log.info(":>>> 开始获取活动域名配置:{}", activityId);
        if (StringUtils.isBlank(activityId)) {
            log.error(":>>> 活动ID为空");
            return null;
        }
        Query query = new Query().addCriteria(Criteria.where("activityId").is(activityId));
        return mongoTemplate.findOne(query, ActivityDominConfig.class);
    }
}
